/**
 * Humanloop API
 * The Humanloop API allows you to interact with Humanloop from your product or service.  You can do this through HTTP requests from any language or via our official Python SDK.  To install the official Python SDK, run the following command:  ```bash pip install humanloop ```  ---  Guides and further details about key concepts can be found in [our docs](https://humanloop.gitbook.io/humanloop-docs/).
 *
 * The version of the OpenAPI document: 3.0.0
 *
 *
 * NOTE: This file is auto generated by Konfig (https://konfigthis.com).
 * https://konfigthis.com
 * Do not edit the class manually.
 */

import type {
  PageInfo,
  PageParameterProperties,
  PageParameters,
} from "./page-types";
import { Pageable, PageRequest } from "./pageable";

export class Page<
  Data extends PageInfo,
  Parameters extends PageParameters
> extends Pageable<Data, Parameters> {
  make(parameters: {
    data: Data;
    initialParameters: Parameters;
    request: PageRequest<Data, Parameters>;
  }): Pageable<Data, Parameters> {
    return new Page(parameters);
  }
  protected get previousParameters(): PageParameterProperties | null {
    return { page: this.data.page - 1 };
  }

  protected get nextParameters(): PageParameterProperties | null {
    return { page: this.data.page + 1 };
  }

  hasPrevious(): boolean {
    return this.data.page > 0;
  }

  hasNext(): boolean {
    return this.data.page * this.data.size < this.data.total;
  }
}
